Strict

Import agfx

Global myBtnScreen:TBtnScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		'DEVICE.SetFps(30)		' default FPS is 60
		
		Super.OnCreate()
				
		myBtnScreen = New TBtnScreen		
		myBtnScreen.Prepare()
				
		Return 0
	End
	
	
End

Class btn_press Extends TCallback

	Field b:TGUIButton

	Method New(obj:TGUIButton)
		Self.b = obj
	End

	Method Call:Void()
		SOUNDS.Find("lazer").Play()
		Print("Button "+Self.b.name+" pressed")
	End

End


Class TBtnScreen Extends TScreen
	
	Field btn:TGUIButton

	' START when app is created
	#Rem
	summary: This function makes something very important 
	The first parameter is called Value1 and can be used to set something
	Be aware that this function returns a String!
	#End
	Method Start:Void()

		IMAGES.LoadAnim("agfx_gui_button2.png",64,48,3,null,False)

		Self.btn = New TGUIButton("BTN_1","agfx_gui_button2",100,100,False)
		Self.btn.OnHit = New btn_press(Self.btn)

		SOUNDS.Load("lazer")
	End
	
	' main app logic loop update
	Method Update:Void()
		Self.btn.Update()
	End
	
	' main app render loop
	Method Render:Void()
		Cls
		btn.Draw()
	End
End
